package com.example.musicdemo.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import com.example.musicdemo.R
import com.example.musicdemo.model.SongListBean
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.item_home.view.*

class HomeItemView : RelativeLayout {

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {
        View.inflate(context, R.layout.item_home, this)
    }

    /**
     * 刷新itemView
     */
    fun setData(data:SongListBean) {
        //歌单名称
        tv_song.text = data.name
        //歌单简介
        tv_tell.text = data.description
        //背景图片
        Picasso.get().load(data.coverImgUrl).into(iv_background)
    }


}